home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Newton Platform Info / Newton 2.0 Sample Code / Localization / CreatingALocale-1 / CreatingALocale.text < prev    next >
Encoding:
Text File  |  1996-02-12  |  3.2 KB  |  84 lines  |  [TEXT/MPS ]

  1. // Text of project CreatingALocale written on 2/12/96 at 3:17 PM
  2. // Beginning of text file Install & Remove
  3.  
  4. /*
  5. **      Newton Developer Technical Support Sample Code
  6. **
  7. **      CreatingALocale  -  Changing the Newton's locale to 24 hour
  8. **                          and making day & month lower case
  9. **
  10. **      by Henry Cate, Newton Developer Technical Support
  11. **
  12. **      Copyright © 1996 by Apple Computer, Inc.  All rights reserved.
  13. **
  14. **      You may incorporate this sample code into your applications without
  15. **      restriction.  This sample code has been provided "AS IS" and the
  16. **      responsibility for its operation is 100% yours.  You are not
  17. **      permitted to modify and redistribute the source as "DTS Sample Code."
  18. **      If you are going to re-distribute the source, we require that you
  19. **      make it clear in the source that the code was descended from
  20. **      Apple-provided sample code, but that you've made changes.
  21. **
  22. **
  23. **      This creates a locale bundle which changes the time format
  24. **      to 24 hour format, and makes the day of the week & month of the
  25. **      year appear appear in lower case text.
  26. **
  27. **      Check the Newton Programmer's Guide for more information about locales
  28. **      and check the article "Newton still needs the card you removed." for
  29. **      more information about how to handle the card being pulled problem
  30. */
  31.  
  32. constant kLocaleName := "MyLocale:PIEDTS";
  33.  
  34.  
  35. InstallScript :=
  36. func(partFrame, removeFrame)
  37. begin 
  38.     // Get the current locale bundle, so if this is deleted 
  39.     // we can restore to the previous locale
  40.     local currentLocale := GetLocale();
  41.     local newLocale := EnsureInternal ( {    // Have as internal so can survive card removal 
  42.         _proto: nil,                        // Create the slot name internal
  43.         title: kLocaleName,                    // Have to be internal, when do RemoveLocale, check for title match
  44.         timeFormat: {
  45.             _proto: nil,    
  46.             timeCycle: kCycle24,            // change to 24 hour cycle
  47.             },
  48.         longDateFormat:{
  49.             _proto: nil,
  50.             longDofWeek: ["sunday", "monday", "tuesday", "wednesday", "thrusday", "friday", "saturday"],
  51.             abbrDofWeek: ["sun", "mon", "tue", "wed", "thr", "fri", "sat"],
  52.             terseDofWeek: ["su", "mo", "tu", "we", "th", "fr", "sa"],
  53.             shortDofWeek: ["s", "m", "t", "w", "t", "f", "s"],
  54.             longMonth: ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"],
  55.             abbrMonth: ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"],
  56.             },
  57.         });
  58.         
  59.     // Set proto's so get the built-in system slots and all the defaults
  60.     newLocale._proto := currentLocale;        
  61.     newLocale.timeFormat._proto := currentLocale.timeFormat;    
  62.     newLocale.longDateFormat._proto := currentLocale.longDateFormat;
  63.         
  64.     // Done creating the locale, so add it to the system collection, then set    
  65.     call kAddLocaleFunc with (newLocale);    
  66.     SetLocale(kLocaleName);            
  67.     
  68.     // Do EnsureInternal so if the card gets pulled, can clean up gracefully 
  69.     removeFrame.(EnsureInternal('OldLocaleTitle)) := EnsureInternal(currentLocale.title);
  70. end;
  71.  
  72. RemoveScript :=
  73. func(removeFrame)
  74. begin
  75.      SetLocale (removeFrame.OldLocaleTitle);     
  76.      // If the OldLocale is no available, RemoveLocale will 
  77.      // pick the first built-in locale 
  78.      call kRemoveLocaleFunc with (kLocaleName);     
  79. end;
  80. // End of text file Install & Remove
  81.  
  82.  
  83.  
  84.